package com.chenxin.wms.controller;

import com.chenxin.common.annotation.Log;
import com.chenxin.common.core.controller.BaseController;
import com.chenxin.common.core.page.TableDataInfo;
import com.chenxin.common.enums.BusinessType;
import com.chenxin.common.utils.poi.ExcelUtil;
import com.chenxin.wms.domain.vo.ZoneVO;
import com.chenxin.wms.service.IZoneService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 库区资料Controller
 *
 * @author gry
 * @date 2025-04-08
 */
@RestController
@RequestMapping("/wms/zone")
public class ZoneController extends BaseController {
    @Autowired
    private IZoneService zoneService;

    /**
     * 查询库区资料列表
     */
    @PreAuthorize("@ss.hasPermi('wms:zone:list')")
    @GetMapping("/list")
    public TableDataInfo list(ZoneVO zoneVo) {
        startPage();
        List<ZoneVO> list = zoneService.selectZoneList(zoneVo);
        return getDataTable(list);
    }

    /**
     * 导出库区资料列表
     */
    @PreAuthorize("@ss.hasPermi('wms:zone:export')")
    @Log(title = "库区资料", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ZoneVO zoneVo) {
        List<ZoneVO> list = zoneService.selectZoneList(zoneVo);
        ExcelUtil<ZoneVO> util = new ExcelUtil<>(ZoneVO.class);
        util.exportExcel(response, list, "库区资料数据");
    }
}
